wayland: use g_signal_handler_disconnect()
authorChristian Hergert <chergert@redhat.com>
Fri, 6 May 2016 08:31:41 +0000 (11:31 +0300)
committerChristian Hergert <chergert@redhat.com>
Fri, 6 May 2016 08:33:12 +0000 (11:33 +0300)
Use of g_signal_handlers_disconnect_by_func() needs to do more work than
necessary to find all the matching handlers. Instead, just hold on to the
signal identifier and remove it directly so we hit the fast path.

Not terribly ground breaking in terms of performance gains, but its done
enough to be worthwhile.

https://bugzilla.gnome.org/show_bug.cgi?id=766049

gdk/wayland/gdkwindow-wayland.c

index eac2e222e9747342b854f457eb9c948a51c4cfef..3b703181619782235035188ae5c50c7f75450e42 100644 (file)
@@ -161,6 +161,8 @@ struct _GdkWindowImplWayland
 
   int saved_width;
   int saved_height;
+
+  gulong parent_surface_committed_handler;
 };
 
 struct _GdkWindowImplWaylandClass
@@ -1144,9 +1146,9 @@ on_parent_surface_committed (GdkWindowImplWayland *parent_impl,
 {
   GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
 
-  g_signal_handlers_disconnect_by_func (parent_impl,
-                                        (gpointer) on_parent_surface_committed,
-                                        window);
+  g_signal_handler_disconnect (parent_impl,
+                               impl->parent_surface_committed_handler);
+  impl->parent_surface_committed_handler = 0;
 
   wl_subsurface_set_desync (impl->display_server.wl_subsurface);
 }
@@ -1180,9 +1182,10 @@ gdk_wayland_window_create_subsurface (GdkWindow *window)
        * content, wait with making the subsurface desynchronized until after
        * the parent was committed.
        */
-      g_signal_connect_object (parent_impl, "committed",
-                               G_CALLBACK (on_parent_surface_committed),
-                               window, 0);
+      impl->parent_surface_committed_handler =
+        g_signal_connect_object (parent_impl, "committed",
+                                 G_CALLBACK (on_parent_surface_committed),
+                                 window, 0);
       gdk_window_request_transient_parent_commit (window);
     }
 }
@@ -1761,9 +1764,12 @@ unmap_subsurface (GdkWindow *window)
 
   parent_impl = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for->impl);
   wl_subsurface_destroy (impl->display_server.wl_subsurface);
-  g_signal_handlers_disconnect_by_func (parent_impl,
-                                        (gpointer) on_parent_surface_committed,
-                                        window);
+  if (impl->parent_surface_committed_handler)
+    {
+      g_signal_handler_disconnect (parent_impl,
+                                   impl->parent_surface_committed_handler);
+      impl->parent_surface_committed_handler = 0;
+    }
   impl->display_server.wl_subsurface = NULL;
 }